﻿
using RTW.DAL;
using RTW.OA.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace RTW.OA.Areas.Common.Servers
{
    public class CookBookServers
    {
	    private readonly IRepository<dinner_cookbook> dinner_cookbookRepository;

        public CookBookServers()
        {
            dinner_cookbookRepository = new DapperRepository<dinner_cookbook>();

        }

        public List<dinner_cookbook> GetData()
        {
            return dinner_cookbookRepository.GetAllEnumerable().ToList();
        }

        public dinner_cookbook GetModelById(string id)
        {
            return dinner_cookbookRepository.GetById(id);
        }

		
        internal void Add(dinner_cookbook model)
        {
            dinner_cookbookRepository.Insert(model);
        }

        internal void Update(dinner_cookbook model)
        {
            dinner_cookbookRepository.Update(model);
        }

		internal void Del(string id)
        {
            dinner_cookbookRepository.DeleteByIds(id);
        }

				      
        internal List<SelectListItem> GetFY_ID()
        {
            List<SelectListItem> tables = new List<SelectListItem>();
            var dstable = dinner_cookbookRepository.SqlWithParamsDynamic("select DEPT_ID Value,DEPT_NAME Text from [dbo].[department]");
            tables.Clear();

            foreach (var dr in dstable)
            {
                string Id = dr.Value.ToString();
                string Title = dr.Text.ToString().Trim();
                tables.Add(new SelectListItem { Value = Id, Text = Title });
            }

            return tables;
        }


                   	}
}